package com.demo.controller;

import com.demo.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import javax.annotation.Resources;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Admin
 * Date: 2023-02-10
 * Time: 17:25
 */
@Component
public class UserController2 {

    //@Resource是java提供的用来注入对象的注解
    //1.属性注入
    //@Resource   //资源
    //private UserService userService;

    //2.Setter注入
    private UserService aaa;

    @Autowired
    public void setUserService(UserService userService) {
        this.aaa = userService;
    }

    //3.构造注入(不支持)
//    private UserService userService;
//
//    @Resource
//    public UserController2(UserService userService) {
//        this.userService = userService;
//    }

    public void doUserController() {
       System.out.println("by userController 2");
       aaa.doService();
   }



}
